# Maintainer: Will Sinatra <wpsinatra@gmail.com>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
pkgname=ruby-rainbow
_gemname=${pkgname#ruby-}
pkgver=3.1.1
pkgrel=0
pkgdesc="colorize printed text on ANSI terminals"
url="https://rubygems.org/gems/rainbow"
arch="noarch"
license="MIT"
depends="ruby"
checkdepends="ruby-rake ruby-bundler ruby-rspec ruby-rspec-core"
source="$pkgname-$pkgver.tar.gz::https://github.com/ku1ik/rainbow/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"
options="!check" #depends on rubocop

prepare() {
	default_prepare

	sed -i '/spec.signing_key/d' $_gemname.gemspec
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install --local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	rm -r "$gemdir"/cache \
		"$gemdir"/build_info \
		"$gemdir"/doc

	cd "$gemdir/gems/$_gemname-$pkgver"
	rm -r README.markdown Changelog.md LICENSE

	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
5aff955e8baf78d99960ec9caa11626f07460085f35966c410bb867dd6454a932d2ee8742729a32eeca186fa338bbb02bce3ee8a452a8b4fb0044bb6ec751bc3  ruby-rainbow-3.1.1.tar.gz
"
